﻿using System;
using System.Collections;
using System.Linq;
using System.Text;
using System.Xml;
/**
 *  @author : Tran Khai Hoang 
 *  @company : Ton Duc Thang university
 */
namespace EcoreSort
{
    class XmlNodeAscendingComparer : IComparer
    {
        public int Compare(Object x, Object y)
        {
            XmlNode node1, node2;
            if (x is XmlNode)
                node1 = x as XmlNode;
            else
                throw new ArgumentException("Object is not of type XmlNode.");

            if (y is XmlNode)
                node2 = y as XmlNode;
            else
                throw new ArgumentException("Object is not of type XmlNode.");
            
            String node1ClassName =  node1.Attributes["name"].InnerText;
            String node2ClassName =  node2.Attributes["name"].InnerText;
            return node1ClassName.CompareTo(node2ClassName);
        }

    }
    class XmlNodeDescendingComparer : IComparer
    {
        public int Compare(Object x, Object y)
        {
            XmlNode node1, node2;
            if (x is XmlNode)
                node1 = x as XmlNode;
            else
                throw new ArgumentException("Object is not of type XmlNode.");

            if (y is XmlNode)
                node2 = y as XmlNode;
            else
                throw new ArgumentException("Object is not of type XmlNode.");
            String node1ClassName = node1.Attributes["name"].InnerText;
            String node2ClassName = node2.Attributes["name"].InnerText;
            return node2ClassName.CompareTo(node1ClassName);
        }

    }
}
